#ifndef MULTIPLICATION_H_JM_20130222
#define MULTIPLICATION_H_JM_20130222

#include "OperationBox.h"
#include "../GenericBoxModel.h"
#include "../../LogConf.h"


namespace jm4bbx {

	template<typename policyType, typename valueType>
	class  MultiplicationTrait {
		JM_USE_LOGGER(ArithmeticOperationTraitLogger)
	public:
		typedef policyType operation_policy;
		typedef typename valueType value_type;

		value_type performeOperation(value_type x, value_type y) const { 
			assert(x.getIndex() == y.getIndex());
			try {
				if (x.getIndex() == y.getIndex()) {
					value_type z(x.getIndex(), x.getKey() * y.getKey());

					LOG_D("x={" << x.getIndex() << ", " <<  x.getKey() << "} * " 
						<< "y={" << y.getIndex() << ", "
						<<  y.getKey() << "} = " 
						<< "z={" << z.getIndex() << ", " <<  z.getKey() << "}");

					return z; 
				}
				else {
					LOG_E("x={" << x.getIndex() << ", " <<  x.getKey() << "} * " 
						<< "y={" << y.getIndex() << ", " <<  y.getKey()
						<< "} >>>> " 
						<< " NESEDIA INDEXY RIADKOV !!!!" );
				}
			}
			catch (...) {
				LOG_W("x={" << x.getIndex() << ", " <<  x.getKey() << "} * " 
					<< "y={" << y.getIndex() << ", " <<  y.getKey() << "} >>>> " 
					<< " EXCEPTION !!!!" );
			}

			return value_type();
		}
	};

}

#endif
